


class Courbe:
    
    def __init__( self ):
        self.__x = None
        self.__y = None
        self.__a = None
        self.__b = None
        self.__d_p1 = None
        self.__d_p2 = None
        
    def setPoints( self, d_p1, d_p2 ):
        self.__d_p1 = d_p1
        self.__d_p2 = d_p2
        
    def resolve( self ):
        if( self.__d_p2["X"] - self.__d_p1["X"] == 0 ):
            self.__a = 0
        else:
            self.__a = ( self.__d_p2["Y"] - self.__d_p1["Y"] ) / ( self.__d_p2["X"] - self.__d_p1["X"] )
            
        self.__b = self.__d_p1["Y"] - self.__a * self.__d_p1["X"]
    
    def getX( self, i_y ):
        if( self.__a == 0 ):
            return 0
        else:
            return ( i_y - self.__b ) / self.__a
    
    def getY( self , i_x ):
        return self.__a * i_x + self.__b